<?php
$server = "localhost";
$uname = "root";
$umm = "root";
$db = "maxik";
$k_name = $_POST['name'];
$k_yax = $_POST['yax'];
$k_til = $_POST['til'];
$k_ads = $_POST['ads'];
$k_jinis = $_POST['jinis'];
$k_kasip = $_POST['kasip'];
$kop = $_POST['kop'];
$kop_ok=implode(";", $kop);
$con = mysqli_connect($server, $uname, $umm, $db);
$id = $_POST['id'];


if ($con) {
    if ($id == 0) {
        $sql_add = "insert into table2(isim,age,ads,sex,kaspi,kizkix,til)values('$k_name','$k_yax','$k_ads','$k_jinis','$k_kasip','$kop_ok','$k_til')";
    } else {
        $sql_add = "update table2 set isim='$k_name', age='$k_yax', ads='$k_ads', sex='$k_jinis', kaspi='$k_kasip',kizkix='$kop_ok' ,til='$k_til'where id = $id";
    }
    $go = mysqli_query($con, $sql_add);
    if ($go) {
        echo '添加成功';
    } else {
        echo '添加失败';
    }
    mysqli_close($con);
} else {
    echo 'kirix maglup boldi' . mysqli_connect_error();
}